<?php
/**
 * @ description : Export the Data.
 * @ class-name : ExportData().
 * @ author : stephen.mo
 * @ date : 05/17/2010
 */

class ExportData {
    
    static public function cssFileList() {
        return array('reset-fonts-grids.css',
                     'default/jquery-ui-1.8.custom.css',
                     'ui.jqgrid-3.6.2.css',
                     'laughing.css',
                     'thickbox.css',
                     'cms-generic.css',
                     'project.css',
                );
    }

    static public function scriptFileList() {
        return array('jquery-1.4.2.min.js',
                     'jquery-ui-1.8.custom.min.js',
                     'json2.js',
                     'jquery.maskedinput-1.2.2.min.js',
                     'tvb-utils.js',
                     'jquery.jqgrid-3.6.2.js',
                     'jquery.bgiframe.min.js',
                     'jquery.ajaxQueue.js',
                     'thickbox-compressed.js',
                     'jquery.validate.js',
                     'jquery-laughing.js',
                     'cms-generic.js',
                     'jquery.autocomplete.js',
                     'canvas.js',
                     'project-init.js',
                );
    }

    static public function setHeader($need_style) {
        if (!$need_style) {
            $body =<<<HTML
                <!doctype html public "-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd">
                <html>
                   <head>
                       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                   </head>
HTML;
            return $body;
        }

        //need some styles.
        $service_get_country = AC::$service_get_country;
        $video_bitrate_default = '["'.implode('","',AC::getInstance()->getConfigSetting(AC::$video_bitrates)).'"]';
        $this_domain = 'http://'.$_SERVER['HTTP_HOST'];
        $body =<<<HTML
                <!doctype html public "-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd">
                <html>
                   <head>
                       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                       <title>Video Bitrate Report Result - MSTAT Reporting Tool</title>
                       <meta http-equiv="Cache-Control" CONTENT="no-cache; max-age=0" />
                       <meta name="keywords" content="" />
                       <meta name="description" content="" />
HTML;
        //add css file list.
        $all_css_files = self::cssFileList();
        foreach($all_css_files as $list) {
            $body .= '<link type="text/css" href="'.$this_domain.'/cdn/css/'.$list.'" rel="stylesheet" />'."\n";
        }


        $body .=<<<HTML
                <style>

                </style>
                 <style type="text/css" media="print">
                    #result .utility{display:none;}
                  </style>
HTML;
        $body .= '<script>
                    var mConfigs = {
                        VIDEO_BITRATES:'.$video_bitrate_default.',
                        URL: { GET_COUNTRY:'." '".$service_get_country."'".'}
                     };
                   </script>
                  </head>';
        
        return $body;
    }
    
    //
    static public function setBody($content) {
        $body = '<body id="" class="">'.
                "\n".
                $content.
                "\n";
        return $body;
    }
    
    //
    static public function setFooter($need_style) {
        $body = null;
        if (!$need_style) return $body;
        $this_domain = 'http://'.$_SERVER['HTTP_HOST'];
        $all_script_list = self::scriptFileList();
        foreach($all_script_list as $list) {
            $body .= '<script src="'.$this_domain.'/cdn/js/'.$list.'"></script>'."\n";
        }
        $body .= '<script>
                    window.status += " - inline js active";
                  </script>
                </body>
            </html>';
        
        return $body;
    }

    static public function getHTMLbody($content,$need_style=true) {
        $body = null;
        $body .= self::setHeader($need_style);
        $body .= self::setBody($content);
        $body .= self::setFooter($need_style);
        return $body;
    }
}

?>